package com.icss.th.common.listener;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.icss.th.subjects.pojo.Subject;
import com.icss.th.subjects.service.SubjectService;

public class SystemInitListener implements ServletContextListener
{
	@Override
	public void contextDestroyed(ServletContextEvent event) 
	{
		
	}

	@Override
	public void contextInitialized(ServletContextEvent event) 
	{
		System.out.println("----------------初始化科目开始------------------");
		
		Map<String, String> map = new HashMap<String, String>();
		Subject root = SubjectService.getRoot();
		for (Subject s1 : root.getChildren())
		{
			System.out.println(s1.getName());
			for (Subject s2 : s1.getChildren())
			{
				System.out.println("    " + s2.getName());
				map.put(String.valueOf(s2.getId()), s2.getName());
			}
		}
		SubjectService.KEY_TYPE_MAP = map;
		
		System.out.println("----------------初始化科目结束------------------");
	}
}
